package sms
import (
	"github.com/xinliangnote/go-gin-api/pkg/errors"
	"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
	sms "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sms/v20210111"
)
func (ms *smsSt) SendVerifyCode(phone_number string, tempid string, verifycode string, expiretime string)(ret_code int32, err error){
	// 发送短信验证码
	request := sms.NewSendSmsRequest()
	request.SmsSdkAppId = common.StringPtr(ms.appid)
	request.SignName = common.StringPtr(ms.signname)
	request.TemplateId = common.StringPtr(tempid)
	request.TemplateParamSet = common.StringPtrs([]string{verifycode, expiretime})
	request.PhoneNumberSet = common.StringPtrs([]string{"+86" + phone_number})
	response, err := ms.client.SendSms(request)
	if err != nil{
		return -1, err;
	}
	if *response.Response.SendStatusSet[0].Code != "Ok" {
		return -1, errors.New(*response.Response.SendStatusSet[0].Code)
	}

	return 0, nil;

}